package com.securitytrace.dataModel;

import javax.swing.table.DefaultTableModel;

import com.securitytrace.model.Address;
import com.securitytrace.util.AddressConvertToVector;
import com.securitytrace.util.AddressConvertUtil;
import com.securitytrace.util.ConvertAdapter;

public class AddressModelToAdd extends DefaultTableModel {

	private static final long serialVersionUID = 6285441594259688626L;
	private static final String[] columns = new String[] { "登录点名称", "值"};
	private ConvertAdapter<Address> addressConvertToVector;
	private Class<?>[] types = new Class[] {
            java.lang.String.class, java.lang.String.class
        };
	private boolean[] canEdit = new boolean [] {
            true, true
    };
	
	public AddressModelToAdd() {
		addressConvertToVector = new AddressConvertToVector();
	}
	@Override
	public boolean isCellEditable(int rowIndex, int columnIndex) {
        return canEdit [columnIndex];
    }

	@Override
	public Class<?> getColumnClass(int columnIndex) {
        return types[columnIndex];
    }
	
	/** 初始化数据 **/
	public void setDataVector(String str) {
		if(null != str) {
			super.setDataVector(AddressConvertUtil.standardStringToVector(str),
					addressConvertToVector.convertToVector(columns));
		}else {
			super.setDataVector(new Object[][]{},columns);
		}
	}
}
